﻿
@{
    ViewBag.Title = "CSContrastView";
    Layout = "~/Views/Shared/_MyLayout.cshtml";
}

@section head{
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts-gl/dist/echarts-gl.min.js"></script>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts-stat/dist/ecStat.min.js"></script>
    @*<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/extension/dataTool.min.js"></script>*@
    @*<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/china.js"></script>
        <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/world.js"></script>
        <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/extension/bmap.min.js"></script>*@
    @*<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/simplex.js"></script>*@

}

@*前期测算对比*@
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>成本一览</legend>
</fieldset>
<div id="main" style="width:100%;height:600px;"></div>
<div id="AZDB" style="width:1000px;height:300px;margin-left:20px;"></div>
<div id="TJDB" style="width:1000px;height:300px;margin-left:20px;"></div>
<div id="SBDB" style="width:1000px;height:300px;margin-left:20px;"></div>
<div id="CLDB" style="width:1000px;height:300px;margin-left:20px;"></div>
<div id="SYFDB" style="width:1000px;height:300px;margin-left:20px;"></div>
<div id="XTFDB" style="width:1000px;height:300px;margin-left:20px;"></div>


<script type="text/javascript">

    var PreEstId = parent.$("#PreEstId").val();
    var PreEstType = parent.$("#ProjectType").val();
    var MapBJ =  @Html.Raw(Json.Encode(ViewBag.MapBJ));
    var MapCS =  @Html.Raw(Json.Encode(ViewBag.MapCS));

    var MapCSCK = @Html.Raw(Json.Encode(ViewBag.MapCSCK));
    var MapCSSJ = @Html.Raw(Json.Encode(ViewBag.MapCSSJ));

    var MapBJCK = @Html.Raw(Json.Encode(ViewBag.MapBJCK));
    var MapBJSJ = @Html.Raw(Json.Encode(ViewBag.MapBJSJ));

    for (var key in MapBJ) {
        if (key.indexOf("Memo") == -1) {
            if (MapBJ[key] == null || MapBJ[key] == "") {
                MapBJ[key] = 0;
            }           
        }
    }
    for (var key in MapCS) {
        if (key.indexOf("Memo") == -1) {
            if (MapCS[key] == null || MapCS[key] == "") {
                MapCS[key] = 0;
            }  
        }
    }






    //成本一览
    //app.title = '前期测算数据对比'
    var builderJson = {
        //"all": 10887000,
        //报价测算柱状图
        "charts": {
            "公司费用": (MapBJ.SJ * MapBJ.DJHTJE + MapBJ.ZJCB + MapBJ.GSGLF * MapBJ.DJHTJE + MapBJ.CoordFee).toFixed(2),
            "电力局费用": (MapBJ.SJF * MapBJ.DJHTJE + MapBJ.JLF * MapBJ.DJHTJE + MapBJ.DJGLF * MapBJ.DJHTJE).toFixed(2),
            "多经合同金额": MapBJ.DJHTJE,
            "业主要求": MapBJ.YZYQ_CF + MapBJ.YZYQ_YHYB + MapBJ.YZYQ_LLLJ + MapBJ.YZYQ_CDZ,
            "总体": MapBJ.InstallFee_WX + MapBJ.InstallFee_KBS + MapBJ.InstallFee_GP + MapBJ.InstallFee_ZP + MapBJ.CivilPrice_HXN + MapBJ.TestFee,
            "专用": MapBJ.EquipFee_ZP + MapBJ.MeterialFee_ZP,
            "公用": MapBJ.EquipFee_GP + MapBJ.MeterialFee_GP,
            "开闭所": MapBJ.EquipFee_KBS + MapBJ.MeterialFee_KBS,
            "外线": MapBJ.CivilPrice_WX + MapBJ.EquipFee_WX + MapBJ.MeterialFee_WX,
        },
        //前期测算柱状图
        "components": {
            "公司费用": (MapCS.SJ * MapCS.DJHTJE + MapCS.ZJCB + MapCS.GSGLF * MapCS.DJHTJE + MapCS.CoordFee).toFixed(2),
            "电力局费用": (MapCS.SJF * MapCS.DJHTJE + MapCS.JLF * MapCS.DJHTJE + MapCS.DJGLF * MapCS.DJHTJE).toFixed(2),
            "多经合同金额": MapCS.DJHTJE,
            "业主要求": MapCS.YZYQ_CF + MapCS.YZYQ_YHYB + MapCS.YZYQ_LLLJ + MapCS.YZYQ_CDZ,
            "总体": MapCS.InstallFee_WX + MapCS.InstallFee_KBS + MapCS.InstallFee_GP + MapCS.InstallFee_ZP + MapCS.CivilPrice_HXN + MapCS.TestFee,
            "专用": MapCS.EquipFee_ZP + MapCS.MeterialFee_ZP,
            "公用": MapCS.EquipFee_GP + MapCS.MeterialFee_GP,
            "开闭所": MapCS.EquipFee_KBS + MapCS.MeterialFee_KBS,
            "外线": MapCS.CivilPrice_WX + MapCS.EquipFee_WX + MapCS.MeterialFee_WX,
        },
        "ie": 9743
    };
    //报价测算馅饼图
    var downloadJson = {
        "公司费用": (MapBJ.SJ * MapBJ.DJHTJE + MapBJ.ZJCB + MapBJ.GSGLF * MapBJ.DJHTJE + MapBJ.CoordFee).toFixed(2),
        "电力局费用": (MapBJ.SJF * MapBJ.DJHTJE + MapBJ.JLF * MapBJ.DJHTJE + MapBJ.DJGLF * MapBJ.DJHTJE).toFixed(2),
        "多经合同金额": MapBJ.DJHTJE,
        "业主要求": MapBJ.YZYQ_CF + MapBJ.YZYQ_YHYB + MapBJ.YZYQ_LLLJ + MapBJ.YZYQ_CDZ,
        "总体": MapBJ.InstallFee_WX + MapBJ.InstallFee_KBS + MapBJ.InstallFee_GP + MapBJ.InstallFee_ZP + MapBJ.CivilPrice_HXN + MapBJ.TestFee,
        "专用": MapBJ.EquipFee_ZP + MapBJ.MeterialFee_ZP,
        "公用": MapBJ.EquipFee_GP + MapBJ.MeterialFee_GP,
        "开闭所": MapBJ.EquipFee_KBS + MapBJ.MeterialFee_KBS,
        "外线": MapBJ.CivilPrice_WX + MapBJ.EquipFee_WX + MapBJ.MeterialFee_WX,
    };
    //前期测算馅饼图
    var themeJson = {
        "公司费用": (MapCS.SJ * MapCS.DJHTJE + MapCS.ZJCB + MapCS.GSGLF * MapCS.DJHTJE + MapCS.CoordFee).toFixed(2),
        "电力局费用": (MapCS.SJF * MapCS.DJHTJE + MapCS.JLF * MapCS.DJHTJE + MapCS.DJGLF * MapCS.DJHTJE).toFixed(2),
        "多经合同金额": MapCS.DJHTJE,
        "业主要求": MapCS.YZYQ_CF + MapCS.YZYQ_YHYB + MapCS.YZYQ_LLLJ + MapCS.YZYQ_CDZ,
        "总体": MapCS.InstallFee_WX + MapCS.InstallFee_KBS + MapCS.InstallFee_GP + MapCS.InstallFee_ZP + MapCS.CivilPrice_HXN + MapCS.TestFee,
        "专用": MapCS.EquipFee_ZP + MapCS.MeterialFee_ZP,
        "公用": MapCS.EquipFee_GP + MapCS.MeterialFee_GP,
        "开闭所": MapCS.EquipFee_KBS + MapCS.MeterialFee_KBS,
        "外线": MapCS.CivilPrice_WX + MapCS.EquipFee_WX + MapCS.MeterialFee_WX,
    };

    var waterMarkText = '远扬能源';

    var canvas = document.createElement('canvas');
    var ctx = canvas.getContext('2d');
    canvas.width = canvas.height = 100;
    ctx.textAlign = 'center';
    ctx.textBaseline = 'middle';
    ctx.globalAlpha = 0.08;
    ctx.font = '20px Microsoft Yahei';
    ctx.translate(50, 50);
    ctx.rotate(-20);
    ctx.fillText(waterMarkText, 0, 0);

    option1 = {
        backgroundColor: {
            type: 'pattern',
            image: canvas,
            repeat: 'repeat'
        },
        tooltip: {},
        title: [{
            text: '成本构成',
            subtext: '总计 ' + builderJson.all,
            x: '25%',
            textAlign: 'center'
        }, {
            text: '报价测算',
            subtext: '总计 ' + Object.keys(downloadJson).reduce(function (all, key) {
                return all + downloadJson[key];
            }, 0),
            x: '75%',
            textAlign: 'center'
        }, {
            text: '前期测算',
            subtext: '总计 ' + Object.keys(themeJson).reduce(function (all, key) {
                return all + themeJson[key];
            }, 0),
            x: '75%',
            y: '50%',
            textAlign: 'center'
        }],
        grid: [{
            top: 50,
            width: '50%',
            bottom: '45%',
            left: 10,
            containLabel: true
        }, {
            top: '55%',
            width: '50%',
            bottom: 0,
            left: 10,
            containLabel: true
        }],
        xAxis: [{
            type: 'value',
            max: builderJson.all,
            splitLine: {
                show: false
            }
        }, {
            type: 'value',
            max: builderJson.all,
            gridIndex: 1,
            splitLine: {
                show: false
            }
        }],
        yAxis: [{
            type: 'category',
            data: Object.keys(builderJson.charts),
            axisLabel: {
                interval: 0,
                rotate: 0
            },
            splitLine: {
                show: false
            }
        }, {
            gridIndex: 1,
            type: 'category',
            data: Object.keys(builderJson.components),
            axisLabel: {
                interval: 0,
                rotate: 0
            },
            splitLine: {
                show: false
            }
        }],
        series: [{
            type: 'bar',
            stack: 'chart',
            z: 3,
            label: {
                normal: {
                    position: 'right',
                    show: true
                }
            },
            data: Object.keys(builderJson.charts).map(function (key) {
                return builderJson.charts[key];
            })
        }, {
            type: 'bar',
            stack: 'chart',
            silent: true,
            itemStyle: {
                normal: {
                    color: '#eee'
                }
            },
            data: Object.keys(builderJson.charts).map(function (key) {
                return builderJson.all - builderJson.charts[key];
            })
        }, {
            type: 'bar',
            stack: 'component',
            xAxisIndex: 1,
            yAxisIndex: 1,
            z: 3,
            label: {
                normal: {
                    position: 'right',
                    show: true
                }
            },
            data: Object.keys(builderJson.components).map(function (key) {
                return builderJson.components[key];
            })
        }, {
            type: 'bar',
            stack: 'component',
            silent: true,
            xAxisIndex: 1,
            yAxisIndex: 1,
            itemStyle: {
                normal: {
                    color: '#eee'
                }
            },
            data: Object.keys(builderJson.components).map(function (key) {
                return builderJson.all - builderJson.components[key];
            })
        }, {
            type: 'pie',
            radius: [0, '30%'],
            center: ['75%', '25%'],
            data: Object.keys(downloadJson).map(function (key) {
                return {
                    name: key.replace('.js', ''),
                    value: downloadJson[key]
                }
            })
        }, {
            type: 'pie',
            radius: [0, '30%'],
            center: ['75%', '75%'],
            data: Object.keys(themeJson).map(function (key) {
                return {
                    name: key.replace('.js', ''),
                    value: themeJson[key]
                }
            })
        }]
    }
    var myChart1 = echarts.init(document.getElementById('main'));
    myChart1.setOption(option1, true);

    //安装成本对比
    option2 = {
        title: {
            text: '安装成本',
            subtext: '价格对比'
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'shadow'
            }
        },
        grid: {
            left: '0%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: {
            type: 'value',
            boundaryGap: [0, 0.01]
        },
        yAxis: {
            type: 'category',
            data: ['报价参考', '报价测算', '测算参考', '前期测算']
        },
        series: [
            {
                name: '',
                type: 'bar',
                data: [MapBJCK.CKInstallFee, MapBJSJ.InstallFee, MapCSCK.CKInstallFee, MapCSSJ.InstallFee],
                itemStyle: {
                    normal: {
                        color: function (params) {
                            var colorList = [
                                '#C1232B', '#B5C334', '#FCCE10', '#E87C25', '#27727B', '#E87C25'
                            ];
                            return colorList[params.dataIndex]
                        }
                    }
                },
            }
        ]
    };
    var myChart2 = echarts.init(document.getElementById('AZDB'));
    myChart2.setOption(option2, true);

    //土建成本对比
    option3 = {
        title: {
            text: '土建成本',
            subtext: '价格对比'
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'shadow'
            }
        },
        grid: {
            left: '0%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: {
            type: 'value',
            boundaryGap: [0, 0.01]
        },
        yAxis: {
            type: 'category',
            data: ['报价参考', '报价测算', '测算参考', '前期测算']
        },
        series: [
            {
                name: '',
                type: 'bar',
                data: [MapBJCK.CKCivilPrice, MapBJSJ.CivilPrice, MapCSCK.CKCivilPrice, MapCSSJ.CivilPrice],
                itemStyle: {
                    normal: {
                        color: function (params) {
                            var colorList = [
                                '#C1232B', '#B5C334', '#FCCE10', '#E87C25', '#27727B', '#E87C25'
                            ];
                            return colorList[params.dataIndex]
                        }
                    }
                },
            }
        ]
    };
    var myChart3 = echarts.init(document.getElementById('TJDB'));
    myChart3.setOption(option3, true);


    //设备成本
    option4 = {
        title: {
            text: '设备费用',
            subtext: '价格对比'
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'shadow'
            }
        },
        grid: {
            left: '0%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: {
            type: 'value',
            boundaryGap: [0, 0.01]
        },
        yAxis: {
            type: 'category',
            data: ['报价参考', '报价测算', '测算参考', '前期测算']
        },
        series: [
            {
                name: '',
                type: 'bar',
                data: [MapBJCK.CKEquipFee, MapBJSJ.EquipFee, MapCSCK.CKEquipFee, MapCSSJ.EquipFee],
                itemStyle: {
                    normal: {
                        color: function (params) {
                            var colorList = [
                                '#C1232B', '#B5C334', '#FCCE10', '#E87C25', '#27727B', '#E87C25'
                            ];
                            return colorList[params.dataIndex]
                        }
                    }
                },
            }
        ]
    };
    var myChart4 = echarts.init(document.getElementById('SBDB'));
    myChart4.setOption(option4, true);


    //材料成本
    option5 = {
        title: {
            text: '材料费用',
            subtext: '价格对比'
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'shadow'
            }
        },
        grid: {
            left: '0%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: {
            type: 'value',
            boundaryGap: [0, 0.01]
        },
        yAxis: {
            type: 'category',
            data: ['报价参考', '报价测算', '测算参考', '前期测算']
        },
        series: [
            {
                name: '',
                type: 'bar',
                data: [MapBJCK.CKMeterialFee, MapBJSJ.MeterialFee, MapCSCK.CKMeterialFee, MapCSSJ.MeterialFee],
                itemStyle: {
                    normal: {
                        color: function (params) {
                            var colorList = [
                                '#C1232B', '#B5C334', '#FCCE10', '#E87C25', '#27727B', '#E87C25'
                            ];
                            return colorList[params.dataIndex]
                        }
                    }
                },
            }
        ]
    };
    var myChart5 = echarts.init(document.getElementById('CLDB'));
    myChart5.setOption(option5, true);


    //试验费成本
    option6 = {
        title: {
            text: '试验费用',
            subtext: '价格对比'
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'shadow'
            }
        },
        grid: {
            left: '0%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: {
            type: 'value',
            boundaryGap: [0, 0.01]
        },
        yAxis: {
            type: 'category',
            data: ['报价参考', '报价测算', '测算参考', '前期测算']
        },
        series: [
            {
                name: '',
                type: 'bar',
                data: [MapBJCK.CKTestFee, MapBJSJ.TestFee, MapCSCK.CKTestFee, MapCSSJ.TestFee],
                itemStyle: {
                    normal: {
                        color: function (params) {
                            var colorList = [
                                '#C1232B', '#B5C334', '#FCCE10', '#E87C25', '#27727B', '#E87C25'
                            ];
                            return colorList[params.dataIndex]
                        }
                    }
                },
            }
        ]
    };
    var myChart6 = echarts.init(document.getElementById('SYFDB'));
    myChart6.setOption(option6, true);


    //协调费成本
    option7 = {
        title: {
            text: '协调费用',
            subtext: '价格对比'
        },
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'shadow'
            }
        },
        grid: {
            left: '0%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: {
            type: 'value',
            boundaryGap: [0, 0.01]
        },
        yAxis: {
            type: 'category',
            data: ['报价参考', '报价测算', '测算参考', '前期测算']
        },
        series: [
            {
                name: '',
                type: 'bar',
                data: [MapBJCK.CKCoordFee, MapBJSJ.CoordFee, MapCSCK.CKCoordFee, MapCSSJ.CoordFee],
                itemStyle: {
                    normal: {
                        color: function (params) {
                            var colorList = [
                                '#C1232B', '#B5C334', '#FCCE10', '#E87C25', '#27727B', '#E87C25'
                            ];
                            return colorList[params.dataIndex]
                        }
                    }
                },
            }
        ]
    };
    var myChart7 = echarts.init(document.getElementById('XTFDB'));
    myChart7.setOption(option7, true);


</script>